<%@ page language="java" pageEncoding="UTF-8"%>
<link href="${baseURL}/themes/plugin/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css" rel="stylesheet" media="screen">
<script type="text/javascript" src="${baseURL}/themes/plugin/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js" charset="UTF-8"></script>
<script type="text/javascript" src="${baseURL}/themes/plugin/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
<script type="text/javascript" src="${baseURL}/js/module/common_edit.js"></script>
<!-- 明细与列表在同一个页面 -->
<div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="editCheckLabel" aria-hidden="true">
	<div class="modal-dialog modal-lg"> <!-- modal-lger -->
		<div class="modal-content FrameRight">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
				<p class="modal-title" id="editCheckLabel">添加</p>
			</div>
			<div class="modal-body cont-table">
				<form method="post" id="formdetail">
					<div class="common-table">
					    <table id="detail_tab"></table>
					</div>
				</form>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-blue" onclick="InterfaceDetail.addById()"> 选择 </button>
				<button type="button" class="btn btn-gray" data-dismiss="modal"> 关闭 </button>
			</div>
		</div>
	</div><!-- /.modal-dialog -->
</div><!-- /.modal -->


<script type="text/javascript">
    //判断第一次点击
    var flag = true; 
	function add(){
		$('#editModal').modal('show');
		$('#editModal').modal({backdrop: 'static'});
		if(flag){
			InterfaceDetail.initTable();
			flag=false;
		}else{
			$("#detail_tab").bootstrapTable("refresh",{
				url: "${baseURL}/intermanage/netinformation/netinformationlistother/listByInterfaceId.do?interfaceId="+interfaceId
			});
		}
	}
	InterfaceDetail = {
			initTable: function(){
				$('#detail_tab').bootstrapTable({
					url: "${baseURL}/intermanage/netinformation/netinformationlistother/listByInterfaceId.do?interfaceId="+interfaceId,
					sidePagination: "server",
		       		dataType:'json',
		       		dataField: 'Rows',
		       		totalField: 'Total',
		       		contentType:'application/x-www-form-urlencoded',
		       		queryParamsType:"undefined",
		       		queryParams:RiskNetOpinion.queryParams,
		            striped: true,                      //是否显示行间隔色
		            pagination: true,
		   	        pageNumber:1,                       //初始化加载第一页，默认第一页
		            pageSize: 15,                       //每页的记录行数（*）
		            pageList: [15, 25, 50, 100],        //可供选择的每页的行数（*）
		   	        clickToSelect: true,                //是否启用点击选中行
		            uniqueId: "id",                     //每一行的唯一标识，一般为主键列
		       		columns: [{
		 	               field: 'checkbox',
			 	           checkbox: true
			           },{
		                   field: 'number',
		                   title: '序号',
		   	               formatter: function (value, row, index) {
		   	                   return (index+1);  
		   	               }
		               },{
		                   field: 'appId',
		                   title: 'APP_ID',
		               },{
		                   field: 'appkey',
		                   title: 'APP_KEY',
					   },{
		                   field: 'isCallInterface',
		                   title: '是否能访问接口',
		                   formatter: function (value, row, index) {
		   	            	 	for(var i=0;i<is_call_interface.length;i++){
		   	            	 		if(is_call_interface[i].id==value){
		   	            	 			return is_call_interface[i].text;
		   	            	 		}
		   	            	 	}
		   	            	 	return '未知'; 
		   	               }
					   },{
		                   field: 'sysCreator',
		                   title: '创建人'
					   }]
				})
			},
			main: function(){
				var _this = RiskNetOpinion;
				_this.initTable();
			},
			//选择权限
			addById: function(){
				var selections = $("#detail_tab").bootstrapTable('getSelections');
				if(selections.length>0){
						var ids = "";
						for(var i=0; i<selections.length; i++){
							ids = ids + selections[i].id + ",";
						}
						ids = ids.substring(0,ids.length-1);
						$.ajax({
							type: "POST",
							url:"${baseURL}/intermanage/interfacepermission/interfacepermissionsave/save.do",
							dataType:'json',
							data:{"ids":ids,"interfaceId":interfaceId},
							success:function(data){
								if(data && data.hasOk == true){
									BT.showSuccess("添加成功!",function(){
										$('#editModal').modal('hide');
									 $("#tb_riskNetOpinion").bootstrapTable("refresh"); 
									});
								}else{
									BT.showError("操作出错!"+data.message);
								}
							}
						})
				}else{
					BT.showWarning("请至少选中一行！"); 
				}
			},
			queryParams:function(params){
				return{
					netId:netId,
					perPageSize: params.pageSize,
					pageNo:params.pageNumber,
			    }
			}
		};
</script>
